<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

return new class extends Migration {
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('user_wechat_open', function (Blueprint $table) {
            $table->id();
            $table->uuid('user_id')->comment('用户id');
            $table->string('unionid', 32)->comment('微信unionid');
            $table->timestamps();
            $table->unique(['user_id', 'unionid'], 'unique_user_unionid');
            $table->index('unionid', 'idx_unionid');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('user_wechat_open');
    }
};
